#ifndef MINIBASIC_CONSOLE_MANAGER_H
#define MINIBASIC_CONSOLE_MANAGER_H

#pragma once

#include "stdafx.h"
#include <string>

namespace MiniBasic
{
    class ConsoleManager
    {
        static const DWORD CREATED_CONSOLE = 1;
        static const DWORD CREATED_INPUT = 2;
        static const DWORD CREATED_OUTPUT = 4;
        static const COORD USE_CURRENT_POS;
        HANDLE hStdIn, hStdOut;
        DWORD creationFlags;
        CONSOLE_SCREEN_BUFFER_INFO originalSettings;

    public:
        ConsoleManager(bool keepConsoleOpen = false, HANDLE hIn = NULL, HANDLE hOut = NULL);
        ~ConsoleManager();

        BOOL FloodAttribute(WORD wAttribute, COORD startLocation = USE_CURRENT_POS, DWORD dwCount = MAXDWORD);
        BOOL FloodChar(WCHAR character, COORD startLocation = USE_CURRENT_POS, DWORD dwCount = MAXDWORD);

        BOOL Clear();
        BOOL ChangeCurrentAttributes(WORD newAttributes);
        
        BOOL MoveCursor(COORD newPosition);
        BOOL ToggleCursor(BOOL on);
        BOOL ResizeWindow(COORD dims);
        void RestoreToOriginal();
        void OutputText(const std::string& text) const;

        bool GetFromUserWithEnter(std::string& value) const;
        mbint GetKey() const;
    };
}

#endif
